package com.rgs.se.oom;

/**
 * @author Ren Gaoshuai
 * @ClassName MetualReference
 * 打印堆栈GC信息 -XX:+PrintGCDetails
 * @date 2022-03-06 12:00
 **/
public class MetualReference {
    public Object instance = null;
    private static final int _1MB = 1024 * 1024;
    private byte[] bytes = new byte[2 * _1MB];


    static{
        i = 0;
    }
    private static int i = 1;

    public static void testGc() {
        MetualReference m1 = new MetualReference();
        MetualReference m2 = new MetualReference();
        m1.instance = m2;
        m2.instance = m1;
        m1 = null;
        m2 = null;

        System.gc();
    }

    public static void main(String[] args) {
        testGc();
    }
}
